complete "yarn dev" to watch every last thing, including transitive less and pug imports#7556
complete "yarn dev" to watch every last thing, including transitive less and pug imports#7556
Conversation
…ess and pug imports
af66281 to
fefa970
Compare
| this.pendingBuilds.set( | ||
| entryId, | ||
| next.finally(() => { | ||
| if (this.pendingBuilds.get(entryId) === next) { | ||
| this.pendingBuilds.delete(entryId); | ||
| } | ||
| }), | ||
| ); |
There was a problem hiding this comment.
🟡 queueBuild cleanup condition always evaluates to false because it compares next against next.finally(…)
The pendingBuilds map is never cleaned up because the finally callback compares the wrong promise reference. pendingBuilds.set(entryId, next.finally(cb)) stores the new promise returned by .finally(), but inside the callback, the check is this.pendingBuilds.get(entryId) === next — comparing the stored finally-wrapped promise against the original next. Since .finally() always returns a new promise object, this comparison is always false, so pendingBuilds.delete(entryId) never executes.
Root cause and impact
The pattern at line 470-477 is:
this.pendingBuilds.set(
entryId,
next.finally(() => {
if (this.pendingBuilds.get(entryId) === next) { // always false
this.pendingBuilds.delete(entryId);
}
}),
);next.finally(cb) returns a different promise object (call it wrapped). The map stores wrapped, but the callback checks get(entryId) === next. Since wrapped !== next, the delete is never reached.
The fix is to capture the wrapped promise and compare against it:
const wrapped = next.finally(() => {
if (this.pendingBuilds.get(entryId) === wrapped) {
this.pendingBuilds.delete(entryId);
}
});
this.pendingBuilds.set(entryId, wrapped);Impact: Settled promises accumulate in pendingBuilds. Because each entry ID only ever has one value in the map, the leak is bounded by the number of LESS files (typically small), and build sequencing is unaffected since chaining onto a settled promise works correctly. The main consequence is that the intended cleanup is silently broken.
| this.pendingBuilds.set( | |
| entryId, | |
| next.finally(() => { | |
| if (this.pendingBuilds.get(entryId) === next) { | |
| this.pendingBuilds.delete(entryId); | |
| } | |
| }), | |
| ); | |
| const wrapped = next.finally(() => { | |
| if (this.pendingBuilds.get(entryId) === wrapped) { | |
| this.pendingBuilds.delete(entryId); | |
| } | |
| }); | |
| this.pendingBuilds.set(entryId, wrapped); | |
Was this helpful? React with 👍 or 👎 to provide feedback.
This change is